package seedmarket

/**
 * Represents a seed in the market. The seed has specific information including name, amount
 * and hardiness.
 * @author Gregory Koutrelakos
 * @version 7.11.12
 *
 */
class Seed {    
	String name
        String scientificName
	Integer amount
	Integer hardiness
	Date dateCreated
	
	/**
	 * Will return the name of the seed
	 */
	String toString() {
		"${name}"
	}
        
         
         /**
          * Seeds can be searched for.
          */
         static searchable = true
	
	/**
	 * Seeds will belong to Users, meaning that a User can have multiple seeds but 
	 * Seeds cannot have multiple Users.
	 */
	static belongsTo = [owner: User]

	/**
	 * Orders the information as well as validates
	 */
    static constraints = {
		name(blank: false)
                scientificName(blank: false)
		amount(min: 0, max: 100)
		hardiness(min: 1, max: 13)
		dateCreated(min: new Date())
    }
}
